/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package services.impl;

import domain.Passport;
import domain.Products;
import domain.Users;
import javax.ejb.LocalBean;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
import services.interfaces.IPassportservices;

/**
 *
 * @author amega
 */
@Stateless
@LocalBean
public class PassportServices extends GenericServiceImpl<Passport> implements IPassportservices {
    
     @PersistenceContext(unitName="RGHPU")
    private EntityManager em;
    
    public PassportServices(){
        super(Passport.class);
    }
    
    @Override
    protected EntityManager getEntityManager() {
        return em;
    }
    
    public Passport getPassportByNumber(String number) {
    try {
            Query q = em.createNamedQuery("Passport.findByNumberPassport").setParameter("numberPassport", number);
            Passport p = (Passport)q.getSingleResult();
           
             return p;
        } catch (Exception e) {
            return  null;
        } 
    }
    
}
